package at.fhooe.mc.android.shiftalarmclock;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ArrayAdapterSettings extends ArrayAdapter<DummyData> {

	// internal list of the relevant data
	List<DummyData> mList;
	AlarmModel a = new AlarmModel();

	public ArrayAdapterSettings(Context _context, int _textViewResourceId,
			List<DummyData> _objects) {

		super(_context, _textViewResourceId, _objects);
		mList = _objects;
	}

	@Override
	public View getView(int _position, View _convertView, ViewGroup _parent) {
		if (_convertView == null) {
			Context c = getContext();
			LayoutInflater inflater = (LayoutInflater) c
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			_convertView = inflater.inflate(R.layout.list_item_layout2, null);
		}

		final DummyData element = mList.get(_position);
		if (element != null) {
			TextView v = null;
			v = (TextView) _convertView.findViewById(R.id.textView1);
			String s;
			if (element.getAlarmTime() == "") {
				s = (element.getHowOften() + " x " + element.getShift());
			} else {
				s = (element.getHowOften() + " x " + element.getShift()
						+ ": " + element.getAlarmTime());
			}
			v.setText(s);
		}
		return _convertView;
	}
}